Skip to content

test(serializers): cover the Genesys AudioHook serializer - #5725

Open
CaptainAni187 wants to merge 1 commit into
pipecat-ai:mainfrom
CaptainAni187:test_genesys_serializer
Open

test(serializers): cover the Genesys AudioHook serializer#5725
CaptainAni187 wants to merge 1 commit into
pipecat-ai:mainfrom
CaptainAni187:test_genesys_serializer

Conversation

@CaptainAni187

Copy link
Copy Markdown

GenesysAudioHookSerializer is 964 lines and has no tests. It is the largest untested module under src/pipecat/, and the only telephony serializer without coverage: Twilio, Exotel and the protobuf serializer all have some.

This adds 20 tests covering the parts a Genesys session depends on.

Handshake and sequencing. open is answered with opened and marks the session open; the response echoes the client's seq as clientseq; the server's own seq increments per message; ping is answered with pong; close is answered with closed and closes the session.

Audio. A round trip through PCMU: PCM out, ulaw on the wire, PCM back at the pipeline rate, with the 8-bit to 16-bit size relationship pinned. Audio is refused in both directions before open arrives and while the session is paused.

Stereo. With ["external", "internal"] negotiated, interleaved audio is de-interleaved to the external channel only.

Control messages. dtmf becomes an InputDTMFFrame; unparseable JSON and unknown message types are ignored rather than raised; position is tracked from the client and a malformed one falls back to zero.

Outbound. InterruptionFrame becomes a barge-in event, EndFrame and CancelFrame become a disconnect, and output variables set through set_output_variables() reach the disconnect message.

Two things worth knowing

Writing these turned up behaviour that is easy to get wrong from the outside, so both are pinned by a test rather than left implicit.

_handle_open negotiates the channel from the media block in the open message and overwrites InputParams.channel. Constructing the serializer with channel=BOTH and then receiving an open that advertises ["external"] leaves it mono. The stereo test sets the channel through the handshake for that reason.

The disconnect message carries action alongside outputVariables, so the output-variables test asserts the specific key rather than the whole parameters object.

Checks

$ pytest tests/test_genesys_serializer.py -q
20 passed

$ pytest tests/test_genesys_serializer.py tests/test_exotel_serializer.py tests/test_serializers.py -q
39 passed

$ ruff check tests/test_genesys_serializer.py
All checks passed!

$ ruff format --check tests/test_genesys_serializer.py
1 file already formatted

No changelog fragment: this is tests only, with no user-facing change. Happy to add one if you would rather every PR carry one.

Everything here documents current behaviour rather than proposing changes. If any assertion pins something you consider a bug rather than the contract, say so and I will turn it into an issue instead.

Adds wire-format and protocol-state coverage for GenesysAudioHookSerializer:
the open/ping/close handshake and its sequence numbering, ulaw audio in both
directions, the open-and-paused gates on audio, external-channel extraction
from interleaved stereo, DTMF and malformed control messages, and the
disconnect and barge-in messages carrying output variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant